import Vue from 'vue'
import Vuex from 'vuex'

import {
	getItem,
	setItem
} from '@/utils/storage.js'

Vue.use(Vuex)

const TOKEN_KEY = 'TOUTIAOUSER'

export default new Vuex.Store({
	state: {
		user: getItem(TOKEN_KEY),
		userPhoto: 'https://tse1-mm.cn.bing.net/th/id/R-C.a23d99ae05cb5a0a352f70989c1b82e1?rik=Cv3Ss1AYVu6mVw&riu=http%3a%2f%2fscimg.jianbihuadq.com%2f202006%2f2020062019313122.jpg&ehk=W5Jfx3f%2ffHh60PbV7xtevhkgqa0MGDh2%2fdfV%2fdkX3hE%3d&risl=&pid=ImgRaw&r=0&sres=1&sresct=1'
	},
	getters: {},
	mutations: {
		setUser(state, data) {
			state.user = data
			setItem(TOKEN_KEY, state.user)
		},
		
		setUserPhoto(state, data) {
			state.userPhoto = data
		},
	},
	actions: {},
	modules: {}
})
